// pages/Alliance_details/Alliance_details.js
var Url = "http://localhost:8085/";
//引入请求代码
var call = require("../../utils/ajax.js")
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        //用户id
        tokenID: "",
        //联盟唯一id
        organization_id: "",
        //联盟详情数据源
        details: "",
        // 待领养数据源
        detailsAdopt: [
            "jfsl",
            "fjsdl"
        ],
        URL: "http://localhost:8085/"
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
                this.setData({
                        URL:app.globalData.URL
                    })
        //获取openid
        let dd = wx.getStorageSync("tokenID");
        this.setData({
            tokenID: dd
        })
        console.log("TOKENID" + this.data.tokenID)
            //列表页跳转传参
        console.log(options);
        var that = this;
        that.data.organization_id = options.id;
        console.log(that.data.organization_id);
        //联盟详情
        this.onLoad_list(options.id);
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },
    // 加载联盟详情
    onLoad_list(id) {
        console.log(id);
        var that = this;
        console.log("加载联盟详情");
        let url = 'Organization/getOrganization/' + id;
        call.getData1(url,function (res) {
            console.log(res)
            that.setData({
                details: res.date.organization,
                detailsAdopt:res.date.pet
            })
        },function (params) {
            
        })
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },
    button1: function() {
        var hh = this;
        console.log(hh.data.details.organization_contact)
        let text = "联系电话："+hh.data.details.organization_contact+"\r\n"+"微信账号："+hh.data.details.organization_wechat+"\r\n"+"联系地址："+hh.data.details.organization_county_area+hh.data.details.organization_city_area+hh.data.details.organization_big_area
       console.log(text)
        wx.setClipboardData({
            data: text,
            success: function(res) {
                wx.getClipboardData({
                    success: function(res) {
                        console.log(res)
                        wx.showToast({
                            title: '复制成功'
                        })
                    }
                })
            }
        })
    }
})